package main

func main() {
	case1()
	case2()
	case3()
	// defer 在执行的时候使用的是原来的值
}

func case3() {
	endInfo := []string{"ok"}
	println("arr string")
	defer println(endInfo[0])

	endInfo[0] = "this use arr string"
}

func case2() {
	endInfo := "ok"
	ptr := &endInfo
	println("start", "case2")
	defer println(*ptr)

	if 1 == 1 {

		*ptr = "ptr value"
		println("ptr value:", *ptr)
		return
	}
}

func case1() {
	endInfo := "ok"
	println("start", "case1")
	defer println(endInfo)

	endInfo = "1==1"
}
